#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <connectpage.h>
#include "tagread.h"

#include "GReader.h"
#include "message.h"
#include "delegate.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

enum
{
    IDLE         = 0, //空闲状态
    readUserdata,     //正在读取用户区数据
    chargeing,        //正在充电
    readTempHumi      //正在读取温湿度
};

typedef enum{
    SINGEL,
    CONTINUOUS
}ReadMode;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    ConnectPage *DevContPage; //设备连接页面
    TAGRead     *ReadPage;
    QTimer      *chargetimer ;
    QMetaObject::Connection connection;
    /* 写标签 */
    /* 读标签 */
    /* 读温湿度 */
    void ReadTempHumi(void);
    void PowerCharge(int ChargeTime);
private:
    void WriteTag(int addr,char *HexStrNum);
    void ReadTag(int addr,int len , ReadMode mode);

    void MsgStop(void);//停止读取

    int state;
    int chargeTimeS;//单位为秒
    int processStep;

public slots:
    void handleTimeout(void);

private slots:
    void on_ReadEPC_triggered();

    void on_ReadWord_clicked();

    void on_WriteWord_clicked();

    void receiveDataRefresh(LogBaseEpcInfo msg);

    void on_ReadTempHumi_clicked();

    void on_StopButton_clicked();

private:
    Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
